import moment from 'moment';

/*
 * @Author: your name
 * @Date: 2021-05-26 19:23:00
 * @LastEditTime: 2021-05-31 01:36:15
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /xiangpan-admin/src/utils/utils.ts
 */
export const formatDateTime = (data: number) =>
  data ? moment(data * 1000).format('YYYY-MM-DD HH:mm:ss') : '';

export const secondsToMinSec = (s: number) => {
  const mimute = Math.floor(s / 60);
  const seconds = s % 60;
  return s
    ? (mimute > 9 ? mimute : `0${mimute}`) +
        ':' +
        (seconds > 9 ? seconds : `0${seconds}`)
    : '00:00';
};
export function GetQueryString(name: string) {
  var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
  var r = window.location.search.substr(1).match(reg);
  if (r != null) return unescape(r[2]);
  return null;
}
